{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 1.什么是函数？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "abs(-3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 2.调用函数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "如果我将字符串传入到abs里会如何？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "bad operand type for abs(): 'str'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-12-6fc10118d3fb>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mabs\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"aaa\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m: bad operand type for abs(): 'str'"
     ]
    }
   ],
   "source": [
    "abs(\"aaa\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "通过？来查看帮助文档"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "abs?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "如果我希望将一系列的负数批量转成正数，abs（）能做到吗？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "abs([-3,-1,-10])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "[abs(number) for number in [-3,-1,-10]]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 3.自定义函数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "求直角三角形斜边长度的函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def c_length(a,b):\n",
    "    \"\"\"返回直角三角形的斜边长度\"\"\"\n",
    "    c = (a ** 2 + b ** 2) ** 0.5\n",
    "    return c\n",
    "\n",
    "c_length(3,4)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 4.传递参数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### （1）位置参数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "位置参数：要求传入的实参顺序与形参顺序一样，也就是基于形参的顺序将每一个实参都关联到函数定义\n",
    "中的形参中。\n",
    "\n",
    "打印出一个考生的基本信息,"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "我的名字是：利威尔\n",
      "性别：男\n",
      "成绩：100\n"
     ]
    }
   ],
   "source": [
    "def message(name,gender,grade):\n",
    "    \"\"\"打印出一个考生的基本信息\"\"\"\n",
    "    print(\"我的名字是：\" + name + \"\\n性别：\" + gender + \"\\n成绩：\" + str(grade))\n",
    "    \n",
    "message(\"利威尔\",\"男\",100)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "位置参数要求函数调用中的实参按照顺序关联到形参中，如果顺序错了，那么得到的结\n",
    "果可能会很滑稽"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### （2）关键字参数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "要求实参和形参直接对应上，即以某形参名称=某实参的形式填写参数，这样就无需考虑顺序\n",
    "了。\n",
    "\n",
    "通过关键字参数的方式输入一个考生的基本信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "我的名字是：mikasa\n",
      "性别：女\n",
      "成绩：100\n"
     ]
    }
   ],
   "source": [
    "def message(name,gender,grade):\n",
    "    \"\"\"打印出一个考生的基本信息\"\"\"\n",
    "    print(\"我的名字是：\" + name + \"\\n性别：\" + gender + \"\\n成绩：\" + str(grade))\n",
    "    \n",
    "message(grade = 100,gender = \"女\",name = \"mikasa\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### （3）默认参数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def message(name,grade,gender = \"男\"):\n",
    "    \"\"\"打印出一个考生的基本信息\"\"\"\n",
    "    print(\"我的名字是：\" + name + \"\\n性别：\" + gender + \"\\n成绩：\" + str(grade))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "我的名字是：艾伦\n",
      "性别：男\n",
      "成绩：80\n"
     ]
    }
   ],
   "source": [
    "message(\"艾伦\",80)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "我的名字是：克里斯塔\n",
      "性别：女\n",
      "成绩：85\n"
     ]
    }
   ],
   "source": [
    "message(\"克里斯塔\",85,\"女\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<b>注：</b> <font color=red>为什么默认参数必须放在没有默认值参数的后面？因为会产生歧义</font>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid character in identifier (<ipython-input-9-bda3a36d69a4>, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[0;36m  File \u001b[0;32m\"<ipython-input-9-bda3a36d69a4>\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m    def message(name,gender = \"男\"，grade):\u001b[0m\n\u001b[0m                                      ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid character in identifier\n"
     ]
    }
   ],
   "source": [
    "def message(name,gender = \"男\"，grade):\n",
    "    \"\"\"打印出一个考生的基本信息\"\"\"\n",
    "    print(\"我的名字是：\" + name + \"\\n性别：\" + gender + \"\\n成绩：\" + str(grade))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### （4）可变参数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+ 实参的需要性不确定"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "例如，我们需要一个函数来得到某人大写的姓名"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'JACK BALLY DAMON'"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def name(first_name,middle_name,last_name):\n",
    "    \"\"\"得到大写的姓名\"\"\"\n",
    "    full_name = first_name + \" \" + middle_name + \" \" + last_name\n",
    "    return full_name.upper()\n",
    "\n",
    "name(\"jack\",\"bally\",\"damon\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "并非所有人都有中间名，那怎么办呢，这时就需要让中间名变成可选的"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def name(first_name,last_name,middle_name = \"\"):\n",
    "    \"\"\"得到大写的姓名\"\"\"\n",
    "    #此处不要写成 if middle_name == True\n",
    "    if middle_name:\n",
    "        full_name = first_name + \" \" + middle_name + \" \" + last_name\n",
    "    else:\n",
    "        full_name = first_name + \" \" + last_name\n",
    "    return full_name.upper()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'JACK BABY'"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "name(\"jack\",\"baby\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'JACK LUCY BABY'"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "name(\"jack\",\"baby\",\"lucy\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+ 传递任意数量的实参 "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "有时候，我们不知道函数要接收多少个实参，当传递的实参数量不确定时，就需要使得实参的数量为任意的。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "例如，当我们需要计算1+2+3或者1+2+3+4+5或者更多的情况时，我们可以这么做："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def super_sum(*numbers):\n",
    "    s = 0\n",
    "    for i in numbers:\n",
    "        s = s + i\n",
    "    return s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "super_sum(1,2,3,4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "15"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "super_sum(1,2,3,4,5)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "将已有的list或tuple中的元素作为可变参数传进去"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "6"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list_1 = [1,2,3]\n",
    "super_sum(*list_1) #注意前面*号"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "20"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tuple_1 = (2,4,6,8)\n",
    "super_sum(*tuple_1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### （5）生成dict的关键字参数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "事先不知道有多少新增信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'age': 24,\n",
       " 'country': '古不列颠王国',\n",
       " 'email': 'soonyoo@126.com',\n",
       " 'gender': 'female',\n",
       " 'grade': 100,\n",
       " 'name': 'saber'}"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def complete_information(name,gender,grade,**others):\n",
    "    \"\"\"得到考生的完整信息\"\"\"\n",
    "    information = {}\n",
    "    information[\"name\"] = name\n",
    "    information[\"gender\"] = gender\n",
    "    information[\"grade\"] = grade\n",
    "    for key,value in others.items():\n",
    "        information[key] = value\n",
    "    return information\n",
    "\n",
    "complete_information(\"saber\",\"female\",100,age = 24,country = \"古不列颠王国\",email=\"soonyoo@126.com\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'age': 24,\n",
       " 'country': '古不列颠王国',\n",
       " 'email': 'soonyoo@126.com',\n",
       " 'gender': 'female',\n",
       " 'grade': 100,\n",
       " 'name': 'saber'}"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "complete_information(name=\"saber\",gender=\"female\",grade=100,age = 24,country = \"古不列颠王国\",email=\"soonyoo@126.com\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### （6）命名关键字参数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "通过双星号**我们可以传入不受数量限制的关键字参数，那如果我们希望能有个限制，只传入\n",
    "我们希望传入的关键字参数，别的不准传入，这时候就需要命名关键字参数来帮助我们实现\n",
    "了"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "saber female 100 24 shilang\n"
     ]
    }
   ],
   "source": [
    "def complete_information(name,gender,grade,*,age,master):\n",
    "    print(name,gender,grade,age,master)\n",
    "    \n",
    "complete_information(\"saber\",\"female\",100,age=24,master=\"shilang\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### （7）参数组合"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def combind_args(x,y=2,*z,**kw):\n",
    "    print(\"x=\",x,\"y=\",y,\"z=\",z,\"kw=\",kw)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x= 1 y= 2 z= () kw= {}\n"
     ]
    }
   ],
   "source": [
    "combind_args(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x= 1 y= 3 z= () kw= {}\n"
     ]
    }
   ],
   "source": [
    "combind_args(1,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x= 1 y= 3 z= (10, 20, 30) kw= {}\n"
     ]
    }
   ],
   "source": [
    "combind_args(1,3,10,20,30)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x= 1 y= 3 z= (10, 20, 30) kw= {'name': 'jack', 'city': 'Beijing'}\n"
     ]
    }
   ],
   "source": [
    "combind_args(1,3,10,20,30,name=\"jack\",city=\"Beijing\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 5.导出与导入模块"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## （1）将函数导出为模块"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "将写好的函数另存为.py文件，然后放置在python的工作路径中"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## （2）导入模块"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+ 直接导入整个模块"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> + import module_name  #导入模块名（即.py文件）\n",
    "+ 当要使用该模块内的函数时，调用方式为：\n",
    "module_name.function_name()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+ 导入特定的函数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> + from module_name import function_name  #导入模块中的1个特定函数\n",
    "+ from module_name import function_name1,function_name2,... #导入模块中的多个函数\n",
    "+ 当要使用该模块内的函数时，不需要使用句点来调用，直接输入函数名调用即可"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+ 使用as给模块指定别名（推荐这种方式）"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> + import module_name as new_name  #导入模块并另起新名字，用的时候直接用新名字即可使用\n",
    "+ 当要使用该模块内的函数时，调用方式为:\n",
    "new_name.function.name()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+ 导入模块中的所有函数（不推荐）"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> + from module_name import *  #导入该模块中的所有函数\n",
    "+ 当要使用该模块内的函数时，不需要使用句点来调用，直接输入函数名称即可，但是有一个很大的问题是，如果该模块内的函数与你目前项目里的函数重名了的话，会覆盖掉重名函数，如果你不清楚导入的模块内的函数是否与你目前项目的函数有重名现象，就会很麻烦，因此不推荐这种方式。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 函数返回多个值问题"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## appand"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def get_image_encoding():\n",
    "    userid_list = []\n",
    "    fr_image_encoding_list = []\n",
    "    fn_image_encoding_list = []\n",
    "    \n",
    "    a = ['123','456']\n",
    "    userid_list.append(a)\n",
    "    \n",
    "    b = ['789','abc']\n",
    "    fr_image_encoding_list.append(b)\n",
    "    \n",
    "    c = ['efg','hijk']\n",
    "    fn_image_encoding_list.append(c)\n",
    "    \n",
    "    return (userid_list,fr_image_encoding_list,fn_image_encoding_list)\n",
    "    \n",
    "   "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['123', '456']\n",
      "['789', 'abc']\n",
      "['efg', 'hijk']\n"
     ]
    }
   ],
   "source": [
    "userid_list = get_image_encoding()[0]\n",
    "fr_image_encoding_list = get_image_encoding()[1]\n",
    "fn_image_encoding_list = get_image_encoding()[2]\n",
    "\n",
    "print(userid_list)\n",
    "print(fr_image_encoding_list)\n",
    "print(fn_image_encoding_list)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## extend"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def get_image_encoding():\n",
    "    userid_list = []\n",
    "    fr_image_encoding_list = []\n",
    "    fn_image_encoding_list = []\n",
    "    \n",
    "    a = ['123','456']\n",
    "    userid_list.extend(a)\n",
    "    \n",
    "    b = ['789','abc']\n",
    "    fr_image_encoding_list.extend(b)\n",
    "    \n",
    "    c = ['efg','hijk']\n",
    "    fn_image_encoding_list.extend(c)\n",
    "    \n",
    "    return (userid_list,fr_image_encoding_list,fn_image_encoding_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['123', '456']\n",
      "['789', 'abc']\n",
      "['efg', 'hijk']\n"
     ]
    }
   ],
   "source": [
    "userid_list = get_image_encoding()[0]\n",
    "fr_image_encoding_list = get_image_encoding()[1]\n",
    "fn_image_encoding_list = get_image_encoding()[2]\n",
    "\n",
    "print(userid_list)\n",
    "print(fr_image_encoding_list)\n",
    "print(fn_image_encoding_list)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<font color=red>注：</font> 如果a值是单个字符或数字，则用 数组.appand(a) <br/>\n",
    "如果a值是数组，则建议使用extend,数组.extend(a)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['123', '456']\n",
      "['789', 'abc']\n",
      "['efg', 'hijk']\n"
     ]
    }
   ],
   "source": [
    "userid_list,fr_image_encoding_list,fn_image_encoding_list = get_image_encoding()\n",
    "print(userid_list)\n",
    "print(fr_image_encoding_list)\n",
    "print(fn_image_encoding_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python [default]",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "469px",
    "left": "329px",
    "top": "171px",
    "width": "269px"
   },
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
